package cn.itcast.hotel.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.List;

@Data
@NoArgsConstructor
public class HotelDoc {
    private Long id;
    private String name;
    private String address;
    private Integer price;
    private Integer score;
    private String brand;
    private String city;
    private String starName;
    private String business;
    private String location;
    private String pic;
    private Object distance;
    private Boolean isAD;
    private List<String> completion;//用来存放给用户自动补全的内容，对于hotel来说，一般酒店名称和商圈就适合用来做自动补全的内容

    public HotelDoc(Hotel hotel) {
        this.id = hotel.getId();
        this.name = hotel.getName();
        this.address = hotel.getAddress();
        this.price = hotel.getPrice();
        this.score = hotel.getScore();
        this.brand = hotel.getBrand();
        this.city = hotel.getCity();
        this.starName = hotel.getStarName();
        this.business = hotel.getBusiness();
        this.location = hotel.getLatitude() + ", " + hotel.getLongitude();
        this.pic = hotel.getPic();
        //要是business包含多个地址，就切分开
        if (this.business.contains("/")){
            String[] split = this.business.split("/");
            this.completion=new ArrayList<>();
            this.completion.add(this.brand);
            Collections.addAll(this.completion,split);
        }else {
            this.completion= Arrays.asList(this.brand,this.business);
        }
    }
}
